"""This module provides functions of basic statistics.

- compute_mode_approx
- compute_mode (TODO)
"""
import numpy as np


def compute_mode_approx(
    nda_data: np.ndarray, nodata: int = -999, bin_count: int = 200
) -> float:
    """Compute the approximately mode value in the given `nda_data` ignoring the nodata value,
       by getting the mode value from a computed histogram of the `nda_data`.

    Parameters
    ----------
    nda_data : numpy.ndarray
        The numpy ndarray input to process.
    nodata : int, optional
        The nodata value in the given `nda_data`.
        Defaults to -999.
    bin_count : int, optional
        The number of bins to use in generating the histogram.
        Default is 200.

    Returns
    -------
    float
        mode value of the histogram
    """
    count, value = np.histogram(
        nda_data[nda_data != nodata], range=(-1, 1), bins=bin_count
    )
    mode_pos = np.argmax(count)
    return 0.5 * (value[mode_pos] + value[mode_pos + 1])


def compute_mode(nda_data, nodata=-999):
    # TODO we should also have a version of getting the mode in an exact way
    raise NotImplementedError
